package com.szsh.aiot.hsm.mapper;

import com.szsh.aiot.hsm.dto.camera.IBatchUpgradeDetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author hongkuan
 */
@Mapper
public interface IBatchUpgradeDetailMapper {

    /**
     *
     * @param ls 批量升级插件详细信息对象
     * @return 1:成功，0:失败
     */
    @Insert({"<script>",
            "insert into I_BATCH_UPGRADE_DETAIL(serno,gatemac,chipModel,broadbandNO,status,description,batchID) values ",
            "(#{item.serno},#{item.gatemac}, #{item.chipModel}, #{item.broadbandNO},#{item.status}, #{item.description},#{item.batchID})",
            "</script>"})
    int insert(@Param("item") IBatchUpgradeDetail ls);

    /**
     * 根据批量ID查询批量升级详细信息
     * @param batchID  批量ID
     * @return 批量升级插件详细信息 列表对象
     */
    @Select("select * from I_BATCH_UPGRADE_DETAIL where batchID=#{batchID} order by serno")
    List<IBatchUpgradeDetail> getBatchDetailsByBatchId(String batchID);

    /**
     *  根据序列号修改 status 和 description
     * @param status 状态
     * @param description 描述
     * @param serno 序列号
     * @return 1:成功 0:失败
     */
    @Update({"update I_BATCH_UPGRADE_DETAIL set status=#{status},description=#{description} where serno=#{serno}"})
    int updateStatus(@Param("status") int status, @Param("description") String description,
                     @Param("serno") String serno);

}
